﻿using System;
using System.Collections.Generic;

namespace FunctionalProgramming.LazyCollections
{
   /// <summary>
   /// Encapsulates work with lazy collections.
   /// </summary>
   public static class LazyCollection
   {
      /// <summary>
      /// Creates lazy collection based on provided evaluation function.
      /// </summary>
      /// <typeparam name="T">Type of elements in resulting collection.</typeparam>
      /// <typeparam name="TEval">Type of data that will be evaluated.</typeparam>
      /// <param name="evaluator">The evaluation function.</param>
      /// <param name="initialValue">The initial value to be evaluated.</param>
      /// <returns></returns>
      public static IEnumerable<T> Unfold<T, TEval>(Func<TEval, Option<T, TEval>> evaluator, TEval initialValue)
      {
         return new LazyEnumerable<T, TEval>(evaluator, initialValue);
      }
   }
}
